# uncompyle6 version 3.8.0
# Python bytecode 3.7.0 (3394)
# Decompiled from: Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: cipher.py


class Cipher:

    def __init__(self, key):
        self.key = key

    def Encrypt(self, plaintext):
        key_length = len(self.key)
        key_as_int = [ord(i) for i in self.key]
        plaintext_int = [ord(i) for i in plaintext]
        ciphertext = []
        for i in range(len(plaintext_int)):
            value = (plaintext_int[i] ^ key_as_int[(i % key_length)]) % 256
            ciphertext.append(value)

        return bytes(ciphertext)

    def Decrypt(self, ciphertext):
        key_length = len(self.key)
        key_as_int = [ord(i) for i in self.key]
        plaintext = ''
        for i in range(len(ciphertext)):
            value = (ciphertext[i] ^ key_as_int[(i % key_length)]) % 256
            plaintext += chr(value)

        return plaintext